<?


	if (isset($_POST['requete'])){
	   executeRequest($_POST['requete']);
	}
	
	
	function getNbLogin($login) {
		$req = mysql_query("SELECT * FROM users WHERE login='".$login."'");
		$num = mysql_num_rows($req);
		
		return $num;
	}
	
	function getPasswdByLogin($login) {
		$req = mysql_query("SELECT * FROM users WHERE login='".$login."'");
		$res = mysql_fetch_object($req);
		
		return($res->passwd);
	}
	
	function executeRequest($sqlScript){
  	initdb();
  	$req = mysql_query($sqlScript);
  	if (!$req){
  	   print "cancel";
    }else{
       print "done";
    }
  }
  
  function initdb(){
    //if (!isset($db)){
      require("connect.inc.php");
      ($dbRmb = mysql_connect("$serveur", "$utilisateur", "$motdepasse")) or die("<CENTER><A style='color:white;background-color:red'> D?ol? probl?e de serveur</a><br><br>Impossible de se connecter au serveur</center><br></td></tr></table></body></html>");
	   mysql_select_db("$database",$dbRmb) or die("<CENTER><A style='color:white;background-color:red'> D?ol? probl?e de serveur</a><br><br>Impossible de se connecter ?la base de donn?s</center><br></td></tr></table></body></html>");
	 //}  
  }
?>
